{include file="public/_meta" title="接口列表"/}

    <nav class="breadcrumb"> <a href="javascript:void(0);">首页</a>
        <span class="c-gray en">&gt;</span>
        <a href="javascript:void(0);">接口管理</a>
        <span class="c-gray en">&gt;</span>
        <a href="javascript:void(0);">接口列表</a>
        <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" >
            <i class="Hui-iconfont">&#xe68f;</i>
        </a>
    </nav>
    <div class="page-container">
        <div class="cl pd-20">
            <div class="text-c">
                <form action="" method="get" class="form form-horizontal" id="form-article-add" enctype="multipart/form-data">
                    <input type="text" class="input-text" style="width:250px" placeholder="请输入接口名称" name="keywords">
                    <button type="submit" class="btn btn-success"  name=""><i class="Hui-iconfont">&#xe665;</i> 搜索接口</button>
                </form>
            </div>
            <div class="cl pd-5 bg-1 bk-gray mt-20">
                <a href="javascript:void(0);" onclick="add_api('新增接口','{:url(\'api/add_api\')}','800','400')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 新增接口</a>
                <a href="javascript:;" onclick="dataDel()" class="btn btn-danger radius">
                    <i class="Hui-iconfont">&#xe6e2;</i> 批量删除
                </a>
                <span class="r">共有数据：<strong></strong> 条</span>
            </div>
            <div class="mt-20">
            <table class="table table-border table-bordered table-hover table-bg table-sort">
                <thead>
                <tr>
                    <th scope="col" colspan="13">接口列表</th>
                </tr>
                <tr class="text-c">
                    <th><input type="checkbox" name="" value=""></th>
                    <th width="40">ID</th>
                    <th width="50">接口名称</th>
                    <th width="80">接口地址</th>
                    <th width="50">请求类型</th>
                    <th width="80">路由模式</th>
                    <th>加密串</th>
                    <th width="100">参数</th>
                    <th width="120">返回数据</th>
                    <th width="40">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                    <tr class="text-c api">
                        <td><input type="checkbox" value="{$vo.id}" name="id[]"></td>
                        <td>{$vo.id}</td>
                        <td>{$vo.api_name}</td>
                        <td>
                            <b>
                                <u style="cursor:pointer" class="text-primary" onclick="api_show('接口详情信息','{:url(\'api/api_show\')}?id={$vo.id}','{$vo.id}','500','300')">{$vo.api_url}</u>
                            </b>
                        </td>
                        <td>{$vo.request_type}</td>
                        <td>{$vo.route_type}</td>
                        <td>{$vo.aes_code}</td>
                        <td>{$vo.api_param}</td>
                        <td>{$vo.return_data}</td>
                        <td class="td-manage">
                            <a title="编辑" href="javascript:;" onclick="edit_api('编辑接口','{:url(\'api/edit_api\')}?id={$vo.id}','{$vo.id}','800','400')" class="ml-5" style="text-decoration:none">
                                <i class="Hui-iconfont">&#xe6df;</i>
                            </a>&nbsp;
                            <a title="删除" href="javascript:void(0);" style="text-decoration:none" onclick="del_api(this,'{$vo.id}')"><i class="Hui-iconfont Hui-iconfont-del3" title="删除"></i>
                            </a>
                        </td>
                    </tr>
                {/volist}
                </tbody>
            </table>
          </div>
        </div>
    </div>

<!--_footer 作为公共模版分离出去-->
{include file="public/_footer" /}
<!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">
    $(function(){
        $('.table-sort').dataTable({
            "aaSorting": [[ 1, "asc" ]],//默认第几个排序
            //"bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} ,//控制列的隐藏显示
                {"orderable":false,"aTargets":[0,2,3,4,5,6,7,8,9]}// 制定列不参与排序
            ]
        });

    });
</script>

<script>
    /*删除接口*/
    function del_api(obj,id){
        layer.confirm('确定要删除吗',function(index){
            $.ajax({
                type:"post",
                url:"{:url('api/del_api')}",
                data:{id:id},
                dataType:"json",
                success:function(msg){
                    if(msg.status == true){
                        $(obj).parents("tr").remove();
                        layer.msg(msg.message,{icon:6,time:2000});
                        setTimeout(jump,1000);
                        function jump(){
                            parent.layer.close(parent.layer.getFrameIndex(window.name));
                        }
                    }else if(msg.status == false){
                        layer.msg(msg.message,{icon:5,time:2000});
                    }
                }
            });
        });
    }
    /*批量删除接口*/
    function dataDel(){
        var arr = [];
        var id = $("input[name='id[]']:checked");
        id.each(function(){
            arr.push($(this).val());
        });
        $.ajax({
            type : "post",
            url : "{:url('api/batch_del_api')}",
            data : {id:arr},
            dataType : "json",
            success : function(msg){
                if(msg.status == true){
                    layer.msg(msg.message,{icon:6,time:1000});
                    setTimeout(jump,1000);
                    function jump(){
                        window.location.replace(location.href);
                    }
                }else if(msg.status == false){
                    layer.msg(msg.message,{icon:5,time:2000});
                }
            }
        });
    }
    /*详情-接口*/
    function api_show(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
    /*新增-接口*/
    function add_api(title,url,id,w,h){
        layer_show(title,url,id,w,h);
    }
    /*修改-接口*/
    function edit_api(title,url,id,w,h){
        layer_show(title,url,w,h);
    }
</script>



